package com.alphas.xixibackendalphas.exception;

import com.alphas.xixibackendalphas.common.BaseResponse;
import com.alphas.xixibackendalphas.common.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ExceptionHandler {
    @org.springframework.web.bind.annotation.ExceptionHandler(BusinessException.class)
    public BaseResponse<?> businessExceptionHandler(BusinessException e){
        log.info("businessException:{}",e.getStatusCode());
        return BaseResponse.error(e.getStatusCode());
    }
    @org.springframework.web.bind.annotation.ExceptionHandler(RuntimeException.class)
    public BaseResponse<?> runtimeExceptionHandler(RuntimeException e){
        log.info("runtimeException:{}",e.getMessage());
        return BaseResponse.error(StatusCode.SERVER_ERROR);
    }

}
